<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="../js/vue.js"></script>
    <title>计算数学</title>
</head>

<body>

   <div id="root">
     <input type="text" v-model="firstName"><br>
     <input type="text" v-model="lastName"><br>
     <span>computed全名：{{fullName}}</span><br>
     <span>computed全名：{{fullName}}</span><br>
     <span>computed全名：{{fullName}}</span><br>
     <span>methods全名：{{fullName1()}}</span><br>
     <span>methods全名：{{fullName1()}}</span><br>
     <span>methods全名：{{fullName1()}}</span><br>
   </div>


    <script>
      let app = new Vue({
        el:'#root',
        data() {
          return {
            firstName:'张',
            lastName:'三'
          }
        },
        methods: {
          fullName1(){
            console.log("methods：每次使用都会加载")
            return this.firstName + '-' + this.lastName;
          }
        },
        computed:{
          fullName(){
            console.log("通过缓存机制，只会加载一次")
            return this.firstName + '-' + this.lastName;
          }
        }
      });

    </script>
</body>

</html>